
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_widget_from_html_core/flutter_widget_from_html_core.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:catguard/config/config.dart';
import 'package:catguard/pages/webview/webview_logic.dart';
import 'package:webview_flutter/webview_flutter.dart';

///
/// webview
///
class WebViewPage extends StatelessWidget {
  WebViewPage({Key? key}) : super(key: key);

  final logic = Get.find<WebViewLogic>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: Config.colorBg,
        appBar: AppBar(
          title: Text(logic.pageTitle),
          centerTitle: true,
        ),
        body: SizedBox(
          width: double.infinity,
          height: double.infinity,
          child: logic.webUrl.isEmpty
              ? Container(
                  decoration: const BoxDecoration(color: Config.colorBg2),
                  padding: EdgeInsets.all(40.w),
                  child: HtmlWidget(
                    logic.temp,
                    textStyle: const TextStyle(color: Config.colorText1),
                  ),
                )
              : WebViewWidget(
                  controller: logic.controller,
                ),
        ));
  }
}
